﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using CRMSimple.LogService.DataConsumer.Abstractions;
using CRMSimple.LogService.DataProtocol.Abstractions;
using BitAuto.EP.CRMLogSystem.Utils;
using BitAuto.EP.FuncPMonitor.Aops;

namespace CRMSimple.LogServices
{
    public class RMQConsumer : IDataConsumer
    {
        private ConfigurationManager config = Singleton<ConfigurationManager>.Instance;
         [FuncPMonitor()]
        public void ConsumeData(DataParam data)
        {
            var res = data.DeserializeDataParam();
            foreach (var item in config.SQLDBConfiguration)
            {
                if (res.ContainsKey(item.LogTableId))
                    item.FillData(res[item.LogTableId]);
            }
            
            //入库
            InPutDB.BulkToDB(config.SQLDBConfiguration);
        }
    }
}
